Page({
  data: {
    list:[],
    name:"",
    chked: "",
    showName: ""
  },
  onLoad(e) {
    var _this = this
    console.log(e);
    
    if(e.num){
      getApp().req({
        url:"/customer/getlistdata/"+e.num,
        cb(res){
          console.log(res);
          
          _this.setData({
            list:res.data[0].ListItems.Items
          })
        }
      })
    }else{
      this.setData({
        list: this.data[e.name]
      })
    }
      this.setData({
        name: e.name,
        chked: e.chked
      })
    console.log(this.data.list);
    
  },
  chkChange(e) {
    // console.log(e);
    var arr = e.detail.value
    var str = "," + arr.join(",") + ","
    var showName = ""
    for(const j in arr){
      for (const i in this.data.list) {
        if(this.data.list[i].ListItemId == arr[j]){
          showName += this.data.list[i].ListItemName + "、"
          break;
        }
      }
    }
    showName = showName.substr(0,showName.length-1)

    this.setData({
      chked: str,
      showName
    })
    console.log(str);
    console.log(showName);
    
    // console.log(proview.data.info);
    
  },
  chkBack() {
    var proview = getCurrentPages()[getCurrentPages().length-2]
    var newlist = proview.data.info
    newlist[this.data.name + "s"] = this.data.chked
    newlist[this.data.name + 'Names'] = this.data.showName
    proview.setData({
      info: newlist
    })
    dd.navigateBack()

  },
});
